package experience;
/*
构造手机类，包含其配置信息：型号（字符串）、内存大小（整数）、存储空间（整数，GB为单位）、价格（整数）。提供带参数的构造函数，重写其equals方法，使得两个相同配置（型号、内存、存储相同即可，价格可不同）的手机为相等的手机。重写其toString函数，打印手机的配置信息，形式为CellPhone [model:xxx, memory:xxx, storage:xxx, price:xxx]
main函数中从键盘读入两个手机对象，比较他们是否相等，输出他们的配置信息。

输入描述：
两个计算机对象，包含型号、内存、存储空间、价格

输出描述：
两个对象是否相等，两个对象的配置信息

裁判测试程序样例：
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        CellPhone c1 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());
        CellPhone c2 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());

        System.out.println(c1.equals(c2));
        System.out.println(c1);
        System.out.println(c2);
    }
}
输入样例：
在这里给出一组输入。例如：

P20 8 64 4999
P20 8 64 4999
输出样例：
在这里给出相应的输出。例如：

true
CellPhone [model:P20, memory:8, storage:64, price:4999]
CellPhone [model:P20, memory:8, storage:64, price:4999]

 */
import java.util.Scanner;
public class J_PTAexperience5_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        CellPhone c1 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());
        CellPhone c2 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());

        System.out.println(c1.equals(c2));
        System.out.println(c1);
        System.out.println(c2);
    }
}

class CellPhone {
    private String model;
    private int memory;
    private int storage;
    private int price;
    public CellPhone(String model, int memory, int storage, int price) {
        this.model = model;
        this.memory = memory;
        this.storage = storage;
        this.price = price;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        CellPhone other = (CellPhone) obj;
        if (memory != other.memory)
            return false;
        if (model == null) {
            if (other.model != null)
                return false;
        }
        else if (!model.equals(other.model))
            return false;
        if (storage != other.storage)
            return false;
        return true;
    }
    @Override
    public String toString() {
        return "CellPhone [model:" + model + ", memory:" + memory + ", storage:" + storage + ", price:" + price + "]";
    }
}